alloy-primitives
Primitive types shared by alloy, foundry, revm, and reth.
Types
- Unsigned integers re-exported from ruint
- Signed integers, as a wrapper around
ruint
integers - Fixed-size byte arrays via [
FixedBytes
]- [
wrap_fixed_bytes!
]: macro for constructing named fixed bytes types - [
Address
], which is a fixed-size byte array of 20 bytes, with EIP-55 and EIP-1191 checksum support - [
fixed_bytes!
], [address!
] and other macros to construct the types at compile time
- [
Examples
This library has straightforward, basic, types. Usage is correspondingly simple. Please consult the documentation for more information.
use ;
// FixedBytes
let n: = fixed_bytes!;
assert_eq!;
assert_eq!;
// Uint
let mut n: U256 = "42".parse.unwrap;
n += U256 from;
assert_eq!;
// Signed
let mut n: I256 = "-42".parse.unwrap;
n = -n;
assert_eq!;
// Address
let addr_str = "0x66f9664f97F2b50F62D13eA064982f936dE76657";
let addr: Address = parse_checksummed.unwrap;
assert_eq!;
assert_eq!;
// Address checksummed with a custom chain id
let addr_str = "0x66F9664f97f2B50F62d13EA064982F936de76657";
let addr: Address = parse_checksummed.unwrap;
assert_eq!;
assert_eq!;